﻿namespace Fiddler
{
    using System;
    using System.ComponentModel;
    using System.Drawing;
    using System.Windows.Forms;

    public class frmAbout : Form
    {
        private IContainer components;
        private PictureBox pbImage;
        private RichTextBox rtbAbout;

        public frmAbout()
        {
            this.InitializeComponent();
        }

        protected override void Dispose(bool disposing)
        {
            if (disposing && (this.components != null))
            {
                this.components.Dispose();
            }
            base.Dispose(disposing);
        }

        internal static void DoAboutBox()
        {
            GC.Collect();
            GC.WaitForPendingFinalizers();
            GC.Collect();
            using (frmAbout about = new frmAbout())
            {
                about.rtbAbout.Text = FiddlerApplication.GetDetailedInfo() + "Send feedback to: fiddler@telerik.com\n\x00a92013 Telerik. All rights reserved.";
                about.rtbAbout.ForeColor = Utilities.GetContrastingTextColor(about.BackColor);
                about.ShowDialog(FiddlerApplication.UI);
            }
        }

        private void frmAbout_KeyDown(object sender, KeyEventArgs e)
        {
            if ((e.KeyData == (Keys.Control | Keys.C)) && (this.rtbAbout.SelectedText.Length < 3))
            {
                e.SuppressKeyPress = e.Handled = true;
                Utilities.CopyToClipboard(this.rtbAbout.Text.Replace("\n", "\r\n"));
            }
            else if (((e.KeyCode == Keys.Escape) || (e.KeyCode == Keys.Return)) || (e.KeyCode == Keys.Space))
            {
                base.Close();
            }
        }

        private void InitializeComponent()
        {
            ComponentResourceManager manager = new ComponentResourceManager(typeof(frmAbout));
            this.rtbAbout = new RichTextBox();
            this.pbImage = new PictureBox();
            ((ISupportInitialize) this.pbImage).BeginInit();
            base.SuspendLayout();
            this.rtbAbout.Anchor = AnchorStyles.Right | AnchorStyles.Left | AnchorStyles.Bottom | AnchorStyles.Top;
            this.rtbAbout.BackColor = Color.White;
            this.rtbAbout.BorderStyle = BorderStyle.None;
            this.rtbAbout.Cursor = Cursors.Default;
            this.rtbAbout.DetectUrls = false;
            this.rtbAbout.Font = new Font("Tahoma", 8.25f);
            this.rtbAbout.Location = new Point(0x3f, 8);
            this.rtbAbout.Name = "rtbAbout";
            this.rtbAbout.ReadOnly = true;
            this.rtbAbout.ScrollBars = RichTextBoxScrollBars.None;
            this.rtbAbout.Size = new Size(0x105, 0xd4);
            this.rtbAbout.TabIndex = 0;
            this.rtbAbout.TabStop = false;
            this.rtbAbout.Text = "";
            this.rtbAbout.WordWrap = false;
            this.pbImage.Image = (Image) manager.GetObject("pbImage.Image");
            this.pbImage.Location = new Point(12, 0x36);
            this.pbImage.Name = "pbImage";
            this.pbImage.Size = new Size(0x25, 0x75);
            this.pbImage.SizeMode = PictureBoxSizeMode.AutoSize;
            this.pbImage.TabIndex = 1;
            this.pbImage.TabStop = false;
            base.AutoScaleDimensions = new SizeF(6f, 13f);
           // base.AutoScaleMode = AutoScaleMode.Font;
            this.BackColor = Color.White;
            base.ClientSize = new Size(0x148, 0xe0);
            base.Controls.Add(this.pbImage);
            base.Controls.Add(this.rtbAbout);
            this.Font = new Font("Tahoma", 8.25f);
          //  base.FormBorderStyle = FormBorderStyle.FixedToolWindow;
            base.KeyPreview = true;
            base.Name = "frmAbout";
            base.ShowIcon = false;
            base.ShowInTaskbar = false;
            base.StartPosition = FormStartPosition.CenterParent;
            this.Text = "About the Fiddler™ Web Debugger";
            base.KeyDown += new KeyEventHandler(this.frmAbout_KeyDown);
            ((ISupportInitialize) this.pbImage).EndInit();
            base.ResumeLayout(false);
            base.PerformLayout();
        }
    }
}

